import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * @creationDate 2019/12/25
 */
import request from "../../utils/request";
import { getEnvConfig } from "../../utils/iocUtils";

var _getEnvConfig = getEnvConfig(),
    CPAAS_IAM = _getEnvConfig.CPAAS_IAM; // import { getCurrentOrganizationId, isTenantRoleLevel } from '@/utils/utils';
// /**
//  * 获取菜单对应的权限集
//  * @param {string} params.service - 权限编码
//  */
// export async function getPermission(params) {
//   const organizationId = getCurrentOrganizationId();
//   return request(
//     `${CPAAS_IAM}/cpaas/v1/${isTenantRoleLevel() ? `${organizationId}/` : ''}menus/buttons`,
//     {
//       query: { ...params },
//       method: 'GET',
//     }
//   );
// }

/**
 * 检验权限
 * @param {array} params.code - 权限编码
 */


export function checkPermission(_x) {
  return _checkPermission.apply(this, arguments);
}

function _checkPermission() {
  _checkPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/menus/check-permissions"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _checkPermission.apply(this, arguments);
}